#include <iostream>
#include <cstdio>
#define OFFSET 500000

int sort_hash[1000001];

int main(int argc, char const *argv[]){
    int n, m;
    while(scanf("%d%d", &n, &m) != EOF){
        for (int i = -500000; i <= 500000; i++)
            sort_hash[i+OFFSET] = 0;
        for (int i = 0; i < n; i++){
            int num;
            scanf("%d", &num);
            sort_hash[num+OFFSET]++;
        }
        for (int i = 500000; i >= -500000; i--){
            if(sort_hash[i+OFFSET] != 0){
                for (int j = 0; j < sort_hash[i+OFFSET]; j++){
                    printf("%d", i);
                    m--;
                    if (m != 0)
                        printf(" ");
                    else{
                        printf("\n");
                        break;
                    }
                }
            }
            if (m == 0)
                break;
        }
    }
    return 0;
}
